package com.woniuxy.enums.article;

import lombok.Getter;

/**
 * 点赞对象类型枚举
 *
 * @author 饶志
 * @version 1.0
 * @since 2025-07-15  17:24
 */
@Getter
public enum ArticleLikeType {

    POST(1, "帖子"),
    COMMENT(2, "评论"),
    ;

    private final Integer targetType;

    private final String description;

    ArticleLikeType(Integer targetType, String description) {
        this.targetType = targetType;
        this.description = description;
    }

    /**
     * 根据类型值获取对应的枚举
     *
     * @param targetType 类型码
     * @return 对应的枚举对象
     */
    public static ArticleLikeType fromType(Integer targetType) {
        for (ArticleLikeType s : values()) {
            if (s.getTargetType().equals(targetType)) {
                return s;
            }
        }
        throw new IllegalArgumentException("Invalid type: " + targetType);
    }
}
